{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "bd812b1c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "API_key = 'KErJq5Agb1znnsUemM6Wl3rfzD3yZaos'\n",
    "API_sercret = 'KXwjBv0j2tkGRYPul09Z8a_CwtYdqEGM'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "cdbb1c32",
   "metadata": {},
   "outputs": [],
   "source": [
    "FaceSet_url = \"https://api-cn.faceplusplus.com/facepp/v3/faceset/create\"\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,    \n",
    "}\n",
    "r = r = requests.post(url = FaceSet_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "9e7558e4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "d010e976",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'faceset_token': 'f89aea14db9f1bca8183a9e3c1980ce8',\n",
       " 'time_used': 159,\n",
       " 'face_count': 0,\n",
       " 'face_added': 0,\n",
       " 'request_id': '1647952213,a7752dae-bd19-4d16-9394-d986e02f6d37',\n",
       " 'outer_id': '',\n",
       " 'failure_detail': []}"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "4b498112",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'f89aea14db9f1bca8183a9e3c1980ce8'"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "faceset_token = r.json()['faceset_token']\n",
    "faceset_token"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8fc24685",
   "metadata": {},
   "source": [
    "### 查询数据集\n",
    "> 描述\n",
    "获取一个 FaceSet 的所有信息，包括此 FaceSet 的 faceset_token, outer_id, display_name 的信息，以及此 FaceSet 中存放的 face_token 数量与列表。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "01be1314",
   "metadata": {},
   "outputs": [],
   "source": [
    "getdetail_url = \"https://api-cn.faceplusplus.com/facepp/v3/faceset/getdetail\"\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'faceset_token':faceset_token\n",
    "}\n",
    "r = requests.post(url = getdetail_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "a32d4553",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "4e62a068",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'faceset_token': 'f89aea14db9f1bca8183a9e3c1980ce8',\n",
       " 'tags': '',\n",
       " 'time_used': 107,\n",
       " 'user_data': '',\n",
       " 'display_name': '',\n",
       " 'face_tokens': [],\n",
       " 'face_count': 0,\n",
       " 'request_id': '1647952218,731a1413-05d4-4f80-b441-3fe919a643f4',\n",
       " 'outer_id': ''}"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c82c7d0a",
   "metadata": {},
   "source": [
    "### 更新数据集描述信息\n",
    "> 更新一个人脸集合的属性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "2e81a956",
   "metadata": {},
   "outputs": [],
   "source": [
    "update_url = \"https://api-cn.faceplusplus.com/facepp/v3/faceset/update\"\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'faceset_token':faceset_token,\n",
    "    'display_name':'20级网新API周二晚班',\n",
    "    'user_data':'59人，23男同学，36女同学'\n",
    "}\n",
    "r = requests.post(url = update_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "ef8ce6e0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'faceset_token': 'f89aea14db9f1bca8183a9e3c1980ce8',\n",
       " 'request_id': '1647952320,06069271-e1f3-41b7-998a-d12322a6ac62',\n",
       " 'time_used': 75,\n",
       " 'outer_id': ''}"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "565d9954",
   "metadata": {},
   "source": [
    "### 增加人脸入数据集合"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "be95d362",
   "metadata": {},
   "source": [
    "#### 人脸检测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bb929bac",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
